const express = require('express');
const router = express.Router();
const { 
  getExercises,
  getExerciseById,
  updateExercise,
  deleteExercise,
  checkExerciseAnswer,
  getRandomExercises,
  getUserExerciseStats
} = require('../controllers/exerciseController');
const { protect } = require('../middlewares/auth');

// 所有练习题路由都需要身份验证
router.use(protect);

// 获取随机练习题
router.get('/random', getRandomExercises);

// 获取用户练习统计
router.get('/stats', getUserExerciseStats);

// 获取所有练习题
router.get('/', getExercises);

// 获取单个练习题
router.get('/:id', getExerciseById);

// 更新练习题
router.put('/:id', updateExercise);

// 删除练习题
router.delete('/:id', deleteExercise);

// 检查练习题答案
router.post('/:id/check', checkExerciseAnswer);

module.exports = router; 